package com.tpyule.tpclass.service.impl;

import com.tpyule.tpclass.dao.NoteDao;
import com.tpyule.tpclass.entity.bean.FailResultBean;
import com.tpyule.tpclass.entity.bean.ResultBean;
import com.tpyule.tpclass.entity.bean.SuccessResultBean;
import com.tpyule.tpclass.entity.bo.NoteCourseBo;
import com.tpyule.tpclass.entity.bo.NoteDetailBo;
import com.tpyule.tpclass.entity.bo.NoteSelfBo;
import com.tpyule.tpclass.entity.dto.NoteQueryDto;
import com.tpyule.tpclass.entity.pojo.Note;
import com.tpyule.tpclass.service.NoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author zzz
 * @version 1.0
 * @date 2020/4/16 12:23
 */
@Service
public class NoteServiceImpl implements NoteService {
    @Autowired
    NoteDao noteDao;
    @Override
    public ResultBean addNote(Note note) {
        ResultBean resultBean = null;
        if(note!=null){
            note.setNoteId(UUID.randomUUID().toString().toUpperCase());
            int result = noteDao.addNote(note);
            if(result!=0) {
                resultBean = new SuccessResultBean(note, "添加成功");
            } else {
                resultBean = new FailResultBean("添加失败");
            }
        }else{
            resultBean = new FailResultBean("数据错误");
        }
        return resultBean;
    }

    @Override
    public List<NoteDetailBo> getListNote(NoteQueryDto noteQueryDto) {
        return noteDao.getListNote(noteQueryDto);
    }

    @Override
    public List<NoteCourseBo> getListInfo(String userId) {
        return noteDao.getListInfo(userId);
    }

    @Override
    public List<NoteSelfBo> getSelfNote(NoteQueryDto noteQueryDto) {
        return noteDao.getSelfNote(noteQueryDto);
    }
}
